package com.atguigu.crowd.handler;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.atguigu.crowd.api.MySQLRemoteService;
import com.atguigu.crowd.constant.CrowdConstant;
import com.atguigu.crowd.entity.vo.PortalTypeVO;
import com.atguigu.crowd.util.CrowdUtil;
import com.atguigu.crowd.util.ResultEntity;

@Controller
public class PortalHandler {
	
	@Autowired
	private MySQLRemoteService mySQLRemoteService;
	
	@RequestMapping("/")
	public String showPortalPage(ModelMap modelMap) {
		
		// 这里实际开发中需要加载数据……
		//获取首页加载的数据
		ResultEntity<List<PortalTypeVO>> portalResultEntity = mySQLRemoteService.getPortalTypeProjectDataRemote();
		if (ResultEntity.SUCCESS.equals(portalResultEntity.getResult())) {
			List<PortalTypeVO> data = portalResultEntity.getData();
			modelMap.addAttribute(CrowdConstant.ATTR_NAME_PORTAL_DATA, data);
		}
		
		return "portal";
	}

}
